<template>
    <view class="container">
        <view class="head">
            <icon size="93" type="info"></icon>
        </view>
        <view class="text">是否核销此订单</view>
        <view class="btn">
            <button @tap="hx" class="weui-btn" :style="'background-color:' + color" type="primary">确定</button>
        </view>
    </view>
</template>

<script>
import cardlist from '@/ymq_canyino2o/dist/cardlist/index';
import gettel from '@/ymq_canyino2o/dist/gettel/index';
var app = getApp();
export default {
    components: {
        cardlist,
        gettel
    },
    data() {
        return {
            moid: '',
            storeid: '',
            smuid: '',
            color: ''
        };
    },
    onLoad: function (t) {
        app.globalData.setNavigationBarColor(this);
        uni.setNavigationBarTitle({
            title: '核销抢购订单'
        });
        var that = this;
        console.log(t);
        var e = decodeURIComponent(t.scene);
        console.log(e);
        var n = e;
        var i = t.storeid;
        this.setData({
            moid: n,
            storeid: i
        });
        uni.showLoading({
            title: '加载中'
        });
        app.globalData.getUserInfo(function (t) {
            console.log(t);
            that.setData({
                smuid: t.id
            });
        });
    },
    onReady: function () {},
    onShow: function () {},
    onHide: function () {},
    onUnload: function () {},
    onPullDownRefresh: function () {},
    onReachBottom: function () {},
    onShareAppMessage: function () {},
    methods: {
        hx: function () {
            var t = this.moid;
            var o = this.storeid;
            var e = this.smuid;
            console.log('扫码人的storeid', o, 'smuid', e, '订单id', t);
            app.globalData.util.request({
                url: 'entry/wxapp/QgHx',
                cachetime: '0',
                data: {
                    order_id: t,
                    store_id: o,
                    user_id: e
                },
                success: function (t) {
                    console.log(t);
                    if ('核销成功' == t.data) {
                        uni.showToast({
                            title: '核销成功',
                            icon: 'success',
                            duration: 1000
                        });
                        setTimeout(function () {
                            if (1 < pages.length) {
                                setTimeout(function () {
                                    uni.navigateBack({});
                                }, 1000);
                            } else {
                                uni.reLaunch({
                                    url: '/ymq_canyino2o/pages/Liar/loginindex'
                                });
                            }
                        }, 1000);
                    } else {
                        uni.showModal({
                            title: '提示',
                            content: t.data
                        });
                        setTimeout(function () {
                            uni.navigateBack({});
                        }, 1000);
                    }
                }
            });
        }
    }
};
</script>
<style>
@import './qghx.css';
</style>
